package com.bdqn.day0915.controller;

import com.bdqn.day0915.entity.User;
import com.bdqn.day0915.service.UserService;
import org.hibernate.annotations.Parameter;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author:Corday
 * @Date:2021/09/15/9:10
 */
@RestController
@RequestMapping("/user")
public class MyController {
    @Resource
    private UserService us;
//    1.获取所有数据
    @RequestMapping("/mygo")
    public  List<User> myGo(){
        return us.findAllUsers();
    }

    @RequestMapping("/play")
    public void play(){
        System.out.println("简单请求!");
        //return;
    }
    @RequestMapping("/{gid}")//实现restful风格
    public String go(@PathVariable Integer gid){
        //此处执行删除
        return "商品："+gid+"删除";
    }
    @RequestMapping("/user")
    public User getUser(){
        User user=new User(10086,"小帅","1234");
      return user;
    }
    @RequestMapping("/getList")
    public List<User> getList(){
        List<User> list= new ArrayList<>();
        list.add(new User(10010,"tom","1234"));
        list.add(new User(10011,"bean","1234"));
        list.add(new User(10012,"mary","1234"));
        list.add(new User(10018,"小美","1234"));
        return list;


    }
}
